<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Glitched Text</title>

        <link rel="stylesheet" href="https://ecomfe.github.io/zrender-doc/public/lib/css/bootstrap.min.css">

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->

        <link rel="stylesheet" href="https://ecomfe.github.io/zrender-doc/public/css/main.css">
    </head>

    <body>
        <nav id="nav" class="navbar navbar-default">
            <div class="container">
                <ul class="nav navbar-nav">
                    <li>
                        <a href="https://ecomfe.github.io/zrender-doc/public/" class="navbar-logo">
                            <img class="navbar-logo-img" src="https://ecomfe.github.io/zrender-doc/public/img/logo.png">
                            <div class="navbar-logo-text">ZRender</div>
                        </a>
                    </li>
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li >
                        <a href="https://ecomfe.github.io/zrender-doc/public/">首页</a>
                    </li>
                    <li >
                        <a href="https://ecomfe.github.io/zrender-doc/public/api.html">文档</a>
                    </li>
                    <li >
                        <a href="https://ecomfe.github.io/zrender-doc/public/examples.html">实例</a>
                    </li>
                    <li>
                        <a href="http://echarts.baidu.com/">ECharts</a>
                    </li>
                </ul>
            </div>
        </nav>


<div id="main">
    <div class="sidebar">
    <div class="sidebar-inner">
        <h3>
            <a href="https://ecomfe.github.io/zrender-doc/public/examples.html">Examples</a>
        </h3>
        <ol>
            
            <li>
                <a href="https://ecomfe.github.io/zrender-doc/public/examples/animation.html"
                    
                >
                    Animation
                </a>
            </li>
            
            <li>
                <a href="https://ecomfe.github.io/zrender-doc/public/examples/bounding_box.html"
                    
                >
                    Bounding Box
                </a>
            </li>
            
            <li>
                <a href="https://ecomfe.github.io/zrender-doc/public/examples/clip_path.html"
                    
                >
                    ClipPath
                </a>
            </li>
            
            <li>
                <a href="https://ecomfe.github.io/zrender-doc/public/examples/glitched_text.html"
                    
                        class="active"
                    
                >
                    Glitched Text
                </a>
            </li>
            
            <li>
                <a href="https://ecomfe.github.io/zrender-doc/public/examples/hello_world.html"
                    
                >
                    Hello World!
                </a>
            </li>
            
            <li>
                <a href="https://ecomfe.github.io/zrender-doc/public/examples/particles.html"
                    
                >
                    Particles
                </a>
            </li>
            
        </ol>
    </div>
</div>


    <div class="content">
        <div class="example-container" style="background: #333"></div>

<script>
window.onload = function() {
    var container = document.getElementsByClassName('example-container')[0];
    var zr = zrender.init(container);

    var w = zr.getWidth();
    var h = zr.getHeight();

    var t1 = new zrender.Text({
        style: {
            text: 'zrender',
            textAlign: 'center',
            textVerticalAlign: 'middle',
            fontSize: 200,
            fontFamily: 'Lato',
            fontWeight: 'bolder',
            textFill: '#0ff',
            blend: 'lighten'
        },
        position: [w / 2 + 5, h / 2]
    });
    zr.add(t1);

    var t2 = new zrender.Text({
        style: {
            text: 'zrender',
            textAlign: 'center',
            textVerticalAlign: 'middle',
            fontSize: 200,
            fontFamily: 'Lato',
            fontWeight: 'bolder',
            textFill: '#f0f',
            blend: 'lighten'
        },
        position: [w / 2, h / 2]
    });
    zr.add(t2);

    var lines = [];
    for (var i = 0; i < 16; ++i) {
        var line = new zrender.Rect({
            shape: {
                x: w * (Math.random() - 0.3),
                y: h * Math.random(),
                width: w * (Math.random() + 0.3),
                height: Math.random() * 8
            },
            style: {
                fill: ['#ff0', '#f0f', '#0ff', '#00f'][Math.floor(Math.random() * 4)],
                blend: 'lighten',
                opacity: 0
            }
        });
        zr.add(line);
        lines.push(line);
    }

    setInterval(function () {
        if (Math.random() > 0.2) {
            t2.attr('position', [w / 2 + Math.random() * 50, h / 2]);

            for (var i = 0; i < lines.length; ++i) {
                lines[i].attr('shape', {
                    x: w * Math.random(),
                    y: h * Math.random(),
                    width: w * Math.random(),
                    height: Math.random() * 8
                });
                lines[i].attr('style', {
                    opacity: 1
                });
            }

            setTimeout(function () {
                t2.attr('position', [w / 2, h / 2]);


                for (var i = 0; i < lines.length; ++i) {
                    lines[i].attr('style', {
                        opacity: 0
                    });
                }
            }, 100);
        }
    }, 500);
};
</script>


        <a class="source-link" target="_blank"
            href="https://raw.githubusercontent.com/ecomfe/zrender-doc/master/src/_examples/glitched_text.md">
            View Source
        </a>
    </div>
</div>

<script src="https://ecomfe.github.io/zrender-doc/public/lib/js/zrender.min.js"></script>

        <script src="https://ecomfe.github.io/zrender-doc/public/lib/js/jquery.min.js"></script>
        <script src="https://ecomfe.github.io/zrender-doc/public/lib/js/bootstrap.min.js"></script>

        <script>
            var _hmt = _hmt || [];
            (function() {
            var hm = document.createElement("script");
            hm.src = "//hm.baidu.com/hm.js?4bad1df23f079e0d12bdbef5e65b072f";
            var s = document.getElementsByTagName("script")[0];
            s.parentNode.insertBefore(hm, s);
            })();

            $(window).scroll(function () {
                if ($(window).scrollTop() === 0) {
                    // Is top
                    $('#nav').removeClass('shadowed');
                }
                else {
                    // Is not top
                    $('#nav').addClass('shadowed');
                }
            });
        </script>
    </body>
</html>

